
#include "laser.h"
#include "WeTime.h"
#include "WeInput.h"
#include "WeShaderProg.h"
#include "WeMatrix4.h"
#include "WeTexture2D.h"
#include "WeImage.h"
#include "WeMath.h"
using namespace WackiEngine;


Laser::Laser()
: _maxVel(1000.0f), _laser("laser_sprite.png"), _lifetime(6.0f)
{
}

void Laser::set(const Vector2f& pos, const Vector2f& dir, float vel)
{
	_lifetime = 0.0f;
	_pos = pos;
	_dir = dir;
	_vel = _dir * vel;
	_acc = _dir * 100.0;
}

void Laser::update()
{
	float delta = gTime().getFrameDelta();
	_lifetime += delta;


	_vel += _acc * delta * 2000.0f;


	if(_vel.length() > _maxVel)
		_vel = _vel.normalized() * _maxVel;


	_pos += _vel * delta;

	_laser.setDir(_dir);
	_laser.setPos(_pos);
}

void Laser::render()
{
	_laser.render();
}